Repository navigation
fix(fleet-paperwork): validate GitHub API response shapes (#6864) - #7021
Conversation
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
28f3ee8 to
8f6c678
Compare
|
Agent note — task 13328 (pr_shepherd, PR #7021 for issue #6864, batch issue #7297), lane code-g, DIRECT. Rebased this PR onto current main (was 305 commits behind, mergeable_state unstable): new head 8f6c678, single commit, diff unchanged in intent (2 files, +243/-11 — fleet_paperwork.py shape validation + tests). Targeted tests on the laptop: python3 -m unittest discover in infra/fleet-paperwork/tests — 29 tests OK. Review state: no Codex review exists on this PR and CodeRabbit skipped review (bot-authored PR) — no findings to disposition on the old head; a fresh Codex round on 8f6c678 is still owed before merge. CI: 5 basic-tier checks queued on the new head, none started (fleet-wide runner backlog). Parked on CI — resume: fresh checks + Codex on 8f6c678, merge when green. |
|
🤖 Agent note · picked up
|
|
🤖 Agent note · done
|
Summary
Validate GitHub API response shapes in fleet-paperwork (issue #6864), so a parseable-but-wrong-shaped body dies with the tool's own diagnostic instead of a raw AttributeError/KeyError/TypeError — including inside
http()'s own error handler:http()gains shape validation: a non-object success body (or non-array for the one array endpoint) dies naming method, URL, HTTP status, and received shape (_shape_name); a non-object error body reports the status, the shape, and still surfaces the raw excerpt; a non-JSON success body dies cleanly. The legitimate array response (GET /app/installations) is carved out by name viaexpect=list.installations()validates its entries are objects;_account_login()tolerates absent/null/non-string account shapes ininstallation_for,token_for(numeric-id check), andcmd_check.assert_repo_in_scopedies cleanly on a repository entry without a stringfull_name(and on non-listrepositories/ non-numbertotal_count) instead of a rawKeyErrorat the start of every command.find_by_exact_titleskips non-object search items instead of crashing on a bare string, and guards theitemsshape..getcalls in create/comment/close are safe by construction now thathttp()guarantees the documented shape.Tests
New
TestResponseShapes(12 tests, transport stubbed as in the probe): error bodies as list/string/number, object error body keeps its message, success bodies with wrong shapes, non-JSON success body, installations dict-instead-of-list and string item, null account tolerance,assert_repo_in_scopewith/withoutfull_name, non-object search items. Full suite:python3 -m unittest discover -s infra/fleet-paperwork/tests— 29 tests OK on the laptop.Merge Danger
Door: Two-way
Blast Radius: Low — the fleet's rate-limit fallback tool; well-shaped flows are unchanged (all pre-existing tests pass), and wrong-shaped flows now fail with a better diagnostic instead of a traceback.
Fixes #6864
🤖 Queue worker lane code-o, task 11098.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.